<route>
    {
        meta: {
            layout: 'index',
            title:'穿心解卡现场信息'
        }
    }  
</route>
<template>
  <div>
    <a-card>
      <div>
        <a-row v-if="selectedReport">
          <a-button type="primary" style="margin-left: auto; margin-bottom: 10px; margin-right: 10px; width: 100px;"
            @click="doReturn">返回</a-button>
        </a-row>
      </div>
      <div v-if="!selectedReport">
        <a-tabs v-model:activeKey="activeKey">
          <!-- <template #leftExtra>
                        <AccidentWell style="margin-right: 16px; width: 180px;" @confirm="getSelectWell">选择已有井
                        </AccidentWell>
                    </template> -->
          <a-tab-pane key="1" tab="信息录入">
            <div>
              <a-form :model="params" name="basic" :label-col="{ span: 8 }">
                <a-card>
                  <template #title>
                    <span>基础信息<span style="color: green">（提示：<span style="color: red">*</span>
                        代表必传内容）</span></span>
                  </template>
                  <a-row>
                    <a-col :span="8">
                      <a-form-item label="井名" name="wellId">
                        <AccidentWell :wellId="params.wellId" style=" width: 180px;" @confirm="getSelectWell">选择已有井
                        </AccidentWell>
                      </a-form-item>
                    </a-col>
                    <a-col :span="8">
                      <a-form-item label="开钻日期" name="drillingDate">
                        <a-date-picker v-model:value="params.drillingDate" format="YYYY-MM-DD" style="width: 180px"
                          placeholder="开钻日期" />
                      </a-form-item>
                    </a-col>
                    <a-col :span="8">
                      <a-form-item label="完钻日期" name="completionDate">
                        <a-date-picker v-model:value="params.completionDate" format="YYYY-MM-DD" style="width: 180px"
                          placeholder="完钻日期" />
                      </a-form-item>
                    </a-col>
                  </a-row>
                  <a-row>
                    <a-col :pull="1" :span="11">
                      <a-form-item label="地理位置" name="wellLocation">
                        <a-input v-model:value="params.wellLocation" style="width: 340px" placeholder="请输入地理位置"></a-input>
                      </a-form-item>
                    </a-col>
                    <a-col :pull="1" :span="11">
                      <a-form-item label="构造位置" name="wellConstruct">
                        <a-input v-model:value="params.wellConstruct" style="width: 370px"
                          placeholder="请输入构造位置"></a-input>
                      </a-form-item>
                    </a-col>
                  </a-row>
                  <a-row>
                    <a-col :span="8">
                      <a-form-item label="井径" name="wellDiameter" :rules="[{ required: true, message: '请输入井径' }]">
                        <a-input-number v-model:value="params.wellDiameter" style="width: 180px" :min="0"
                          addon-after="mm" />
                      </a-form-item>
                    </a-col>
                    <a-col :span="8">
                      <a-form-item label="钻井设备" name="drillingEquipment">
                        <a-select v-model:value="params.drillingEquipment" style="width: 180px">
                          <a-select-option v-for="item of drillingEquipment" :value="item" :key="item">
                            {{ item }}</a-select-option>
                        </a-select>
                      </a-form-item>
                    </a-col>
                    <a-col :span="8">
                      <a-form-item label="地层岩性" name="lithology">
                        <lithology-select style="width: 180px" @confirm="getLithology"
                          :value="params.lithology"></lithology-select>
                      </a-form-item>
                    </a-col>
                    <a-col :span="8">
                      <a-form-item label="钻具扣型" name="drillToolType" :rules="[{ required: true, message: '请选择钻具扣型' }]">
                        <buckle-type-select style="width: 180px" :buckleType="buckleType" v-model:value="buckleType"
                          @confirm="getBuckleType"></buckle-type-select>
                      </a-form-item>
                    </a-col>
                    <a-col :span="8">
                      <a-form-item label="钻具最大外径" name="maxDrillingOuterDiameter"
                        :rules="[{ required: true, message: '请输入钻具最大外径' }]">
                        <a-input-number v-model:value="params.maxDrillingOuterDiameter" style="width: 180px" :min="0"
                          addon-after="mm" />
                      </a-form-item>
                    </a-col>
                    <a-col :span="8">
                      <a-form-item label="造斜点" name="obliquePointDeep">
                        <a-input v-model:value="params.obliquePointDeep" style="width: 180px" addon-after="m"
                          placeholder="请输入造斜点" />
                      </a-form-item>
                    </a-col>
                    <a-col :span="8">
                      <a-form-item label="卡点井斜" name="pointWellSlope">
                        <a-input-number v-model:value="params.pointWellSlope" style="width: 180px" :min="0"
                          addon-after="°" placeholder="请输入卡点井斜" />
                      </a-form-item>
                    </a-col>
                    <a-col :span="8">
                      <a-form-item label="卡点方位" name="pointWellLocation">
                        <a-input v-model:value="params.pointWellLocation" style="width: 180px" addon-after="°"
                          placeholder="请输入卡点方位"></a-input>
                      </a-form-item>
                    </a-col>
                    <a-col :span="8">
                      <a-form-item label="狗腿度" name="stuckPointsDoglegDegree">
                        <a-input v-model:value="params.stuckPointsDoglegDegree" style="width: 180px" addon-after="°"
                          placeholder="请输入狗腿度"></a-input>
                      </a-form-item>
                    </a-col>
                    <a-col :span="8">
                      <a-form-item label="增/降斜点1" name="riseDeclinePoint1">
                        <a-input v-model:value="params.riseDeclinePoint1" style="width: 180px" addon-after="m"
                          placeholder="第一处增/降斜点"></a-input>
                      </a-form-item>
                    </a-col>
                    <a-col :span="8">
                      <a-form-item label="井斜1" name="wellSlope1">
                        <a-input v-model:value="params.wellSlope1" style="width: 180px" addon-after="°"
                          placeholder="第一处井斜"></a-input>
                      </a-form-item>
                    </a-col>
                    <a-col :span="8">
                      <a-form-item label="方位1" name="azimuth1">
                        <a-input v-model:value="params.azimuth1" style="width: 180px" addon-after="°"
                          placeholder="第一处方位"></a-input>
                      </a-form-item>
                    </a-col>
                    <a-col :span="8">
                      <a-form-item label="狗腿度1" name="doglegDegree1">
                        <a-input v-model:value="params.doglegDegree1" style="width: 180px" addon-after="°"
                          placeholder="第一处狗腿度" />
                      </a-form-item>
                    </a-col>
                    <a-col :span="8">
                      <a-form-item label="增/降斜点2" name="riseDeclinePoint2">
                        <a-input v-model:value="params.riseDeclinePoint2" style="width: 180px" addon-after="m"
                          placeholder="第二处增/降斜点"></a-input>
                      </a-form-item>
                    </a-col>
                    <a-col :span="8">
                      <a-form-item label="井斜2" name="wellSlope2">
                        <a-input v-model:value="params.wellSlope2" style="width: 180px" addon-after="°"
                          placeholder="第二处井斜"></a-input>
                      </a-form-item>
                    </a-col>
                    <a-col :span="8">
                      <a-form-item label="方位2" name="azimuth2">
                        <a-input v-model:value="params.azimuth2" style="width: 180px" addon-after="°"
                          placeholder="第二处方位" />
                      </a-form-item>
                    </a-col>
                    <a-col :span="8">
                      <a-form-item label="狗腿度2" name="dogleg_degree2">
                        <a-input style="width: 180px" v-model:value="params.dogleg_degree2" addon-after="°"
                          placeholder="第二处狗腿度" />
                      </a-form-item>
                    </a-col>
                    <a-col :span="8">
                      <a-form-item label="电缆型号" name="cableModel">
                        <a-button style="width: 180px" @click="openToolModal('cable')">
                          {{ buttonCable }}</a-button>
                      </a-form-item>
                    </a-col>
                    <a-col :span="8">
                      <a-form-item label="电缆投产日期" name="putDate">
                        <a-date-picker v-model:value="params.putDate" format="YYYY-MM-DD" style="width: 180px"
                          placeholder="投产日期" />
                      </a-form-item>
                    </a-col>
                    <a-col :span="8">
                      <a-form-item label="拉力测试日期" name="tensileTestDate">
                        <a-date-picker v-model:value="params.tensileTestDate" format="YYYY-MM-DD" style="width: 180px"
                          placeholder="拉力测试日期" />
                      </a-form-item>
                    </a-col>
                    <a-col :span="8">
                      <a-form-item label="电缆接头" name="cableGlands">
                        <a-input v-model:value="params.cableGlands" style="width: 180px" placeholder="请输入电缆接头" />
                      </a-form-item>
                    </a-col>
                    <a-col :span="8">
                      <a-form-item label="仪器串信息" name="combination" :rules="[{ required: true, message: '请选择仪器串信息' }]">
                        <a-button style="width: 180px" @click="openToolModal('combination')">
                          {{ buttonCombination }}</a-button>
                      </a-form-item>
                    </a-col>
                    <a-col :span="8">
                      <a-form-item label="仪器弱点" name="instrumentWeaknesses">
                        <a-input style="width: 180px" v-model:value="params.instrumentWeaknesses" placeholder="请输入仪器弱点" />
                      </a-form-item>
                    </a-col>
                    <a-col :span="8">
                      <a-form-item label="仪器抓捞位置" name="salvagePosition">
                        <a-input style="width: 180px" v-model:value="params.salvagePosition" placeholder="请输入仪器抓捞位置" />
                      </a-form-item>
                    </a-col>
                    <a-col :span="8">
                      <a-form-item label="最小抗拉伸力" name="minTensileResistance">
                        <a-input-number style="width: 180px" v-model:value="params.minTensileResistance" :min="0"
                          addon-after="lbf" placeholder="请输入最小抗拉伸力" />
                      </a-form-item>
                    </a-col>
                    <a-col :span="8">
                      <a-form-item label="最小抗压缩力" name="minCompressiveForces">
                        <a-input-number style="width: 180px" v-model:value="params.minCompressiveForces" :min="0"
                          addon-after="lbf" placeholder="请输入最小抗压缩力" />
                      </a-form-item>
                    </a-col>
                    <a-col :span="8">
                      <a-form-item label="马笼头" name="bridle">
                        <a-button style="width: 180px" @click="openToolModal('bridle')">{{
                          buttonbridle
                        }}</a-button>
                      </a-form-item>
                    </a-col>
                  </a-row>
                  <a-row>
                    <a-col :push="2" :span="14">
                      <a-space v-for="(drill, index) in dynamicValidateForm.drills" :key="drill.id"
                        style="display: flex; " align="baseline">
                        <a-form-item label="钻头程序" :name="['drills', index, 'depth']" style="margin-left: -180px">
                          <a-input-group style="width: 600px" compact>
                            <a-input-number v-model:value="drill.outerDiameter" class="site-input-right"
                              style="width: 220px; text-align: center" placeholder="外径(mm)" :min="0" addon-after="mm" />
                            <a-input v-model:value="value13" class="site-input-split"
                              style="width: 35px; pointer-events: none" placeholder="~" disabled />
                            <a-input style="width: 225px;" v-model:value="drill.deep" placeholder="请输入钻头深度范围"></a-input>
                          </a-input-group>
                        </a-form-item>
                        <a-form-item>
                          <a-button style="width: 130px; margin-left: 80px" v-if="dynamicValidateForm.drills.length > 1"
                            class="dynamic-delete-button" :disabled="dynamicValidateForm.drills.length === 1"
                            type="dashed" block @click="removeDrills(drill)">
                            <MinusCircleOutlined />删除行
                          </a-button>
                        </a-form-item>
                      </a-space>
                    </a-col>
                    <a-button type="dashed" style="width: 100%;" block @click="addDomain()">
                      <PlusOutlined />添加钻头程序
                    </a-button>
                  </a-row>
                </a-card><br />
                <a-card>
                  <template #title>
                    <span>其他信息</span>
                  </template>
                  <a-row>
                    <a-col :pull="4" :span="24">
                      <a-form-item label="其它说明" name="otherNotes">
                        <a-textarea v-model:value="params.otherNotes" style="width: 100%" :rows="3" />
                      </a-form-item>
                    </a-col>
                  </a-row>
                  <a-row>
                    <a-col :span="12">
                      <a-form-item label="联系方式" name="phoneNumber">
                        <a-input style="width: 200px" v-model:value="params.phoneNumber" placeholder="138xxxxxxxx" />
                      </a-form-item>
                    </a-col>
                    <a-col :span="8">
                      <a-form-item label="填报单位" name="unit">
                        <a-input style="width: 200px" v-model:value="params.unit" placeholder="中国石油测井公司" />
                      </a-form-item>
                    </a-col>
                  </a-row>
                </a-card>
              </a-form>
              <a-button type="primary" style="width: 100%; margin-top: 10px;" @click="getSubmit">确认提交</a-button>
            </div>
          </a-tab-pane>
          <a-tab-pane key="2" tab="上传记录">
            <HistoryInfo :result="result" @editInfo="editInfo"></HistoryInfo>
          </a-tab-pane>
        </a-tabs>
        <!-- 钻头选择弹窗 -->
        <AntdConfirmModal title="钻头选择" ref="bitModalRef" width="700px" :keepSlot="false" @confirm="addTool('drill')">
          <drill-bit-popup></drill-bit-popup>
        </AntdConfirmModal>
        <!-- 电缆选择弹窗 -->
        <AntdConfirmModal title="电缆选择" ref="cableModalRef" width="1000px" :keepSlot="false" @confirm="addTool('cable')">
          <cable-popup-page></cable-popup-page>
        </AntdConfirmModal>
        <!-- 选择仪器串推荐组合弹窗 -->
        <AntdConfirmModal :showConfirm="false" title="仪器串选择" ref="combinationModalRef" width="1200px">
          <InstrumentInfo :combinationId="params.combinationId" :sOpen="sOpen" @getCombId="getCombId">
          </InstrumentInfo>
        </AntdConfirmModal>
        <!-- 马笼头选择弹窗 -->
        <AntdConfirmModal title="马笼头选择" ref="bridleModalRef" width="1000px" :keepSlot="false"
          @confirm="addTool('bridle')">
          <bridle-popup-page></bridle-popup-page>
        </AntdConfirmModal>
      </div>
      <!-- 详细信息 -->
      <view v-if="selectedReport">
        <cardUnlockingDetail :reportId="selectedReport"></cardUnlockingDetail>
      </view>
    </a-card>
  </div>
</template>
<script setup>
import { ref } from 'vue';
import ThreadCardApi from "@/api/salvage/threadCard.js";
import accidentApi from '@/api/salvage/accidentAlert.js'
import GeoLithology from '@/api/geo/lithology.js'
import { WellDatas } from '@/custom/salvage/constant/address.js'  //新建井判断
import cardUnlockingDetail from './detail'
import InstrumentInfo from "./drawer/InstrumentInfo.vue";
import AccidentWell from '@/custom/salvage/components/AccidentWell'
import WellCombination from "@/api/tool/combination.js";
import WellHorsehead from "@/api/tool/horsehead.js";
import WellCable from "@/api/tool/cable.js";
import { drillingEquipment } from '@/custom/salvage/constant/report.js'
import BuckleTypeSelect from '@/custom/salvage/components/buckleTypeSelect.vue';
import DrillBitPopup from "@/custom/well/components/DrillBitPopup.vue";
import HistoryInfo from "../cardUnlocking/drawer/historyInfo.vue";
import LithologySelect from '@/custom/salvage/components/LithologySelect'
import CablePopupPage from '@/custom/well/components/CablePopupPage'
import BridlePopupPage from '@/custom/well/components/BridlePopupPage'
import dayjs from 'dayjs'
import "dayjs/locale/zh-cn"
import "moment/locale/zh-cn"
import moment from "moment";
import useApp from "@/hooks";
import useUserStore from "@/store/modules/user";
const userStore = useUserStore();
const { $, proxy } = useApp();
const result = ref(null)
const dynamicValidateForm = ref({
  drills: [],
});
const selectedReport = ref(false)
// const query = ref({ pageNum: 1, pageSize: 10, sortBy: 'id', searchKey: '' });
const params = ref({
  wellId: '',
  azimuth1: '',
  azimuth2: "",
  cableGlands: "",
  cableId: "",
  combinationId: '',
  completionDate: "",
  stuckPointsDoglegDegree: '',
  doglegDegree1: '',
  dogleg_degree2: "",
  drillList: [],
  drillToolType: [],
  drillingDate: '',
  drillingEquipment: '',
  fillDate: '',
  fillPerson: '',
  horseHeadFileId: '',
  horseHeadId: '',
  // instrumentLength: 0,
  instrumentWeaknesses: '',
  lithology: '',
  // maxOuterDiameter: 0,
  maxDrillingOuterDiameter: 0,
  minCompressiveForces: 0,
  minTensileResistance: 0,
  obliquePointDeep: '',
  otherNotes: '',
  phoneNumber: '',
  pointWellLocation: '',
  pointWellSlope: '',
  putDate: '',
  riseDeclinePoint1: '',
  riseDeclinePoint2: '',
  salvagePosition: '',
  tensileTestDate: '',
  unit: '',
  wellDiameter: 0,
  wellSlope1: '',
  wellSlope2: '',
  wellConstruct: '',
  wellLocation: '',
});
const defaultParams = ref($.freeStore(params.value));
const buttonCable = ref("选择电缆");
const buttonCombination = ref("选择仪器串");
const buttonbridle = ref("选择马笼头");
const open = ref(false)
const sOpen = ref(false)
const activeKey = ref('1');
const state = ref('新建');
const bitModalRef = ref(null);
const cableModalRef = ref(null);
const combinationModalRef = ref(null);
const bridleModalRef = ref(null);
const buckleType = ref([]) //存储扣型

watch(() => activeKey.value, () => {
  //历史信息
  let uid = localStorage.getItem('userId')
  if (activeKey.value == "2") {
    const query = { order: "DESC", pageNum: "1", pageSize: "99999", searchKey: "", sortBy: "id", };
    if (userStore.isAdmin !== true) {
      // 不是超级管理员时
      query.createUserId = uid
    }
    ThreadCardApi.queryLastList(query).then((res) => {
      //   console.log('watch-历史记录', res);
      result.value = res.content;
    });
  }
});
// 添加一个钻头
const addDomain = () => {
  dynamicValidateForm.value.drills.push({
    outerDiameter: null,
    deep: null,
    name: `钻头${dynamicValidateForm.value.drills.length + 1}`,
    id: Date.now(),
  });
};
// 移除一个钻头
const removeDrills = (item) => {
  let index = dynamicValidateForm.value.drills.indexOf(item);
  if (index !== -1) {
    dynamicValidateForm.value.drills.splice(index, 1);
  }
};
// 获取仪器串id
function getCombId(e) {
  params.value.combinationId = e
  combinationModalRef.value.closeModal();
  showCombination(e)
}
// 获得已存在的井方案
function getSelectWell(e) {
  resetParams(params.value)
  console.log('params.value', params.value);
  let querySurvey = { order: "DESC", pageNum: 1, pageSize: 10, sortBy: "id", wellId: e };
  accidentApi.queryList(querySurvey).then((response) => {
    let accidentData = response.content[0]
    for (const key in accidentData) {
      if (accidentData.hasOwnProperty(key) && params.value.hasOwnProperty(key)) {
        params.value[key] = accidentData[key];
      }
    }
    showCable(params.value.cableId)
    showCombination(params.value.combinationId)
  })
}

// 打开工具弹窗
function openToolModal(e) {
  console.log('openToolModal', e);
  if (e == 'drill') {
    bitModalRef.value.openModal()
  } else if (e == 'cable') {
    cableModalRef.value.openModal()
  } else if (e == 'bridle') {
    bridleModalRef.value.openModal()
  } else if (e == 'combination') {
    combinationModalRef.value.openModal()
    // console.log(params.value.combinationId)
    if (params.value.combinationId) {
      sOpen.value = true
    } else {
      sOpen.value = false
    }
  }
}
// 添加工具信息
function addTool(e) {
  console.log('addTool', e);
  if (e == 'cable') {
    let cableData = JSON.parse(localStorage.getItem('selectCables'))
    console.log('cableData', cableData);
    params.value.cableId = cableData[0].id
    showCable(cableData[0].id)
    cableModalRef.value.closeModal();
  } else if (e == 'bridle') {
    let bridleData = JSON.parse(localStorage.getItem('selectBridle'))
    console.log('bridleData', bridleData);
    params.value.horseHeadFileId = bridleData[0].fileId
    params.value.horseHeadId = bridleData[0].id
    buttonbridle.value = `${bridleData[0].horseheadId}`
    bridleModalRef.value.closeModal();
  }
}
// 电缆信息展示
function showCable(id) {
  if (id) {
    WellCable.queryOne(id).then(res => {
      console.log('电缆', res);
      buttonCable.value = `已选择${res.diameter}mm的电缆`
    })
  } else {
    buttonCable.value = "选择电缆"
  }
}
// 仪器串信息展示
function showCombination(id) {
  if (id) {
    WellCombination.queryOne(id).then(res => {
      console.log('仪器串', res);
      buttonCombination.value = `已选择${res.combinationName}`
    })
  } else {
    buttonCombination.value = "选择仪器串"
  }
}
//马笼头信息展示
function showHorseHead(id) {
  if (id) {
    WellHorsehead.getOne(id).then(res => {
      console.log('马笼头', res);
      buttonbridle.value = `已选择${res.horseheadId}`
    })
  } else {
    buttonbridle.value = "选择马笼头"
  }
}

// 获取岩性列表
function getLithology(e) {
  GeoLithology.getOne(e).then(res => {
    params.value.lithology = res.lithologyName
  })
}
// 获取扣型列表
function getBuckleType(e) {
  console.log('扣型列表', e);
  params.value.drillToolType = e
}
//编辑
function editInfo(data) {
  console.log("编辑", data)
  state.value = '编辑'
  activeKey.value = '1'
  // 扣型
  buckleType.value = []
  data.drillToolType?.forEach((res, index) => {
    buckleType.value[index] = res;
  });
  //日期处理
  if (data.putDate) { data.putDate = dayjs(data.putDate, 'YYYY-MM-DD') }
  if (data.tensileTestDate) { data.tensileTestDate = dayjs(data.tensileTestDate, 'YYYY-MM-DD') }
  if (data.completionDate) { data.completionDate = dayjs(data.completionDate, 'YYYY-MM-DD') }
  if (data.drillingDate) { data.drillingDate = dayjs(data.drillingDate, 'YYYY-MM-DD') }

  params.value = data
  // 钻头
  dynamicValidateForm.value.drills = []
  let drillStart = 0
  data.drillList?.forEach((e) => {
    dynamicValidateForm.value.drills.push({
      outerDiameter: e.outerDiameter,
      start: drillStart,
      deep: e.deep,
      name: e.name,
      id: e.deep,
    });
    drillStart = e.deep
  });
  showCable(data.cableId)
  showCombination(data.combinationId)
  showHorseHead(data.horseHeadId)
}
// 提交
async function getSubmit() {
  params.value.drillList = dynamicValidateForm.value.drills;
  let currentTime = new Date()
  params.value.fillDate = moment(currentTime).format('YYYY-MM-DD')
  // 获取系统当前用户名
  params.value.fillPerson = localStorage.getItem('userName')
  // 日期格式化
  if (params.value.drillingDate) { params.value.drillingDate = dayjs(params.value.drillingDate).format('YYYY-MM-DD') }
  if (params.value.completionDate) { params.value.completionDate = dayjs(params.value.completionDate).format('YYYY-MM-DD') }
  if (params.value.putDate) { params.value.putDate = dayjs(params.value.putDate).format('YYYY-MM-DD') }
  if (params.value.tensileTestDate) { params.value.tensileTestDate = dayjs(params.value.tensileTestDate).format('YYYY-MM-DD') }

  // 判空
  if (params.value.wellId == '' || params.value.wellId == undefined) { $.showToast({ title: '井名不允许为空', icon: 'warn' }) }
  else if (!params.value.cableId) { $.showToast({ title: '请选择电缆', icon: 'warn' }) }
  else if (!params.value.combinationId) { $.showToast({ title: '请选择仪器串', icon: 'warn' }) }
  else if (params.value.wellDiameter == 0) { $.showToast({ title: '请输入井径', icon: 'warn' }) }
  else if (params.value.maxDrillingOuterDiameter == 0) { $.showToast({ title: '请输入钻具最大外径', icon: 'warn' }) }
  else if (params.value.drillList.length == 0 ||
    params.value.drillList[params.value.drillList.length - 1].outerDiameter == null ||
    params.value.drillList[params.value.drillList.length - 1].deep == null) {
    $.showToast({
      title: '钻头数据不允许为空',
      icon: 'warn'
    })
  } else {
    if (state.value == '编辑') {
      ThreadCardApi.updateOne(params.value).then(res => {
        $.showToast({
          title: '修改成功',
          icon: 'success'
        })
        selectedReport.value = res.id
      })
    } else {
      ThreadCardApi.createOne(params.value).then(res => {
        params.value = $.freeStore(defaultParams.value)
        open.value = false
        $.showToast({
          title: '新建成功',
          icon: 'success'
        })
        console.log('createOne', res);
        WellDatas(res.id, res.wellId)  //新建井是否已存在判断
        selectedReport.value = res.id
      })
    }
    resetParams(params.value)
  }
}
// 返回
function doReturn() {
  selectedReport.value = false
  resetParams(params.value)
}
// 重置params对象
function resetParams(obj) {
  for (let key in obj) {
    if (Array.isArray(obj[key])) {
      // console.log('重置params数组', obj[key]);
      obj[key] = []; // 清空数组
    } else {
      obj[key] = null; // 重置属性
    }
  }
  state.value = '新建'
  buckleType.value = []
  dynamicValidateForm.value.drills = []
  buttonCombination.value = "选择仪器串"
  buttonCable.value = "选择电缆"
  buttonbridle.value = "选择马笼头"
}

function openDrawer() {
  open.value = true;
}
defineExpose({
  openDrawer: openDrawer
})
</script>
<style scoped>
.steps-content {
  margin-top: 16px;
  border: 1px dashed #e9e9e9;
  border-radius: 6px;
  background-color: #fafafa;
  min-height: 200px;
  text-align: center;
  padding-top: 80px;
}

[data-theme='dark'] .steps-content {
  background-color: #2f2f2f;
  border: 1px dashed #404040;
}
</style>